package com.lanou.zy.projecta.util;

import android.util.Log;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by dllo on 15/11/9.
 */
public class CheckEditText {

//    /**
//     * 验证是否是手机号码
//     *
//     * @param str
//     * @return
//     */
//    public static boolean isMobile(String str) {
//        Pattern pattern = Pattern.compile("1[0-9]{10}");
//        Matcher matcher = pattern.matcher(str);
//        if (matcher.matches()) {
//            return true;
//        } else {
//            return false;
//        }
//    }

    /**
     * 判断是否是合法手机号
     *
     * @param mobiles
     * @return
     */
    public static boolean isMobile(String mobiles) {
//      Pattern p = Pattern.compile("[1][358]\\\\d{9}");
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }

    /**
     * 验证邮箱输入是否合法
     *
     * @param strEmail
     * @return
     */
    public static boolean isEmail(String strEmail) {
        String strPattern = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$";


        Pattern p = Pattern.compile(strPattern);
        Matcher m = p.matcher(strEmail);
        return m.matches();
    }

    /**
     * 判断密码是否正确
     * */

    public static boolean isPsw(String psw) {
        String strPattern = "^[\\@A-Za-z0-9\\!\\#\\$\\%\\^\\&\\*\\.\\~]{6,22}$";

        Pattern p = Pattern.compile(strPattern);
        Matcher m = p.matcher(psw);
        Log.d("CheckEditText", psw);
        return m.matches();
    }



}
